﻿/**************************************************************************************
 * CrmDotNetCodeMigrator
 * Tools to assist the Dynamics CRM developer when moving their code from
 * CRM 4.0 to CRM 2011.
 *
 * @copyright    Copyright (c) 2013, CRM Accelerators (http://www.crmaccelerators.net)
 * @license      Microsoft Public License (Ms-PL)
 * @developer    Mitch Milam (http://blogs.infinite-x.net)
 * @version      0.1
 *
 * THIS SOFTWARE IS PROVIDED BY CRM Accelerators ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL CRM Accelerators BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 **************************************************************************************/

using System;
using System.IO;
using System.Text;

namespace CreateVisualStudioMacros
{
    public static class Utility
    {
        public static void WriteToFile(string fileName, string message)
        {
            using (var writer = new StreamWriter(fileName))
            {
                writer.Write(message);
            }
        }

        public static void WriteToFile(string fileName, StringBuilder sb)
        {
            using (var writer = new StreamWriter(fileName))
            {
                writer.Write(sb.ToString());
            }
        }

        public static void UpdateStatus(string message, bool newline)
        {
            if (newline)
            {
                Console.WriteLine(message);
            }
            else
            {
                Console.Write(message);
            }
        }

        public static void ShowError(string message)
        {
            Console.WriteLine("ERROR: {0}", message);
        }

        public static void ShowError(StringBuilder sb)
        {
            Console.WriteLine("ERROR: {0}", sb);
        }
    }
}
